package cn.top.system.controller;

import cn.top.model.AjaxResult;
import cn.top.system.entity.SysMenu;
import cn.top.system.entity.TreeSelect;
import cn.top.system.service.ISysMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author tutu
 * @since 2024-08-10
 */
@Api
@RestController
@RequestMapping("/system/sysMenu")
public class SysMenuController {

    @Autowired
    private ISysMenuService sysMenuService;

    @ApiOperation(value = "构造树形菜单")
    @GetMapping("/tree")
    public AjaxResult treeselect(){
        List<SysMenu> menus = sysMenuService.list();
        List<TreeSelect> sysMenus = sysMenuService.buildTreeSelect(menus);
        return AjaxResult.success(sysMenus);
    }
}
